﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Edit.aspx.cs" Inherits="SysAdmin_Template_News_Edit" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
</head>
<body>
    <script type="text/javascript">
        $(function () {
            $('#site_model_news_edit_textarea_<%=news_type%>').xheditor({
                tools: 'full',
                html5Upload: true,
                upMultiple: 4,
                upLinkUrl: '/bugController/upload.action',
                upLinkExt: 'zip,rar,txt,doc,docx,xls,xlsx',
                upImgUrl: '/bugController/upload.action',
                upImgExt: 'jpg,jpeg,gif,png'
            });

            $("#news_edit_img_upload_<%=news_type%>").uploadify({
                height: 30,
                formData: { name_copy: 'cfzs_system', attachmentName: "新闻的图片显示", attachmentType: "news_img", modelKey: '<%=news_key%>' },
                swf: 'jsLib/uploadify/uploadify.swf',
                uploader: 'Ashx/UploadAttachment.ashx',
                width: 120,
                multi: false,
                buttonText: "选择上传文件",
                onUploadSuccess: function (file) {
                    //新闻图片标识上传完成后加载显示
                    $("#news_edit_img_<%=news_type%>").attr("src", "Ashx/ShowNewsImage.ashx?news_key=<%=news_key%>");
                }
            });
            $("#news_edit_att_<%=news_type%>").uploadify({
                height: 30,
                formData: { name_copy: 'cfzs_system', attachmentName: "", attachmentType: "news_att", modelKey: '<%=news_key%>' },
                swf: 'jsLib/uploadify/uploadify.swf',
                uploader: 'Ashx/UploadAttachment.ashx',
                width: 120,
                multi: false,
                buttonText: "选择上传文件",
                onUploadStart: function (file) {
                    $("#news_edit_att_<%=news_type%>").uploadify("settings", "attachmentName", document.getElementById("news_edit_att_title_<%=news_type%>").value);
                },
                onUploadSuccess: function (file) {
                    //新闻附件上传完成后加载附件列表
                    show_news_edit_att_<%=news_type%>();
                }
            });

            //初始化图片
            $("#news_edit_img_<%=news_type%>").attr("src", "Ashx/ShowNewsImage.ashx?news_key=<%=news_key%>");
            //初始化附件
            show_news_edit_att_<%=news_type%>();
        });

        //删除附件
        function news_edit_del_att_<%=news_type%>(att_key) {
            $.messager.confirm('提示', '你确定要删除该行数据么?', function (r) {
                if (r) {
                    $.ajax({
                        type: "POST",
                        url: 'Template/News/List.aspx?news_code=' + '<%=news_type%>',
                        data: "paramType=DelAtt&att_key=" + att_key,
                        dataType: "json",
                        success: function (msg) {
                            if (msg.success) {
                                show_news_edit_att_<%=news_type%>();
                            }
                        },
                        error: function (e, ex) {
                            $.messager.alert('错误提示', '删除失败！');
                        }

                    });
                }
            });

        }

        //显示新闻附件列表
        function show_news_edit_att_<%=news_type%>() {
            $.ajax({
                type: "POST",
                url: 'Ashx/GetNewsAtt.ashx?news_key=' + '<%=news_key%>' + '&' + "news_type=<%=news_type%>" + "&is_edit=1",
                dataType: "json",
                success: function (msg) {
                    if (msg.success) {
                        $("#news_edit_att_title_<%=news_type%>").html(msg.msg);
                    }
                },
                error: function (e, ex) {
                    $.messager.alert('错误提示', '显示新闻附件列表失败！');
                }

            });
        }

    </script>

    <link href="jsLib/uploadify/uploadify.css" rel="stylesheet" />
    <div style="text-align: center;">
        <form id="site_model_news_edit_<%=news_type%>" method="post">
            <input type="hidden" name="news_type" value="<%=news_type%>" />
            <table class="tableForm" style="width: 100%">
                <tr>
                    <th style="width: 50px;">标题</th>
                    <td>
                        <input name="newsTitle" class="easyui-validatebox" data-options="required:true" style="width: 90%;" value="<%=news_title.ToString() %>" /></td>
                    <td rowspan="4" style="width: 200px; text-align: center; vertical-align: middle;">
                        <img id="news_edit_img_<%=news_type%>" name="news_img" src="" style="height: 98%; width: 98%;" /></td>
                </tr>
                <tr>
                    <th style="width: 50px;">新闻来源</th>
                    <td>
                        <input name="newsSource" style="width: 90%;" value="<%=news_source.ToString() %>" /></td>
                </tr>
                <tr>
                    <th style="width: 50px;">作者</th>
                    <td>
                        <input name="newsAuthor" style="width: 200px;" value="<%=news_author.ToString() %>" /></td>
                </tr>
                <tr>
                    <th style="width: 50px;">关键字</th>
                    <td>
                        <input name="newsKeyWord" style="width: 90%;" value="<%=news_keyword.ToString() %>" /></td>
                </tr>
                <tr>
                    <th style="width: 50px;">显示图片</th>
                    <td colspan="2">
                        <input id="news_edit_img_upload_<%=news_type%>" type="button" value="上传新闻图片" />
                    </td>
                </tr>
                <tr>
                    <th>内容</th>
                    <td colspan="2">
                        <textarea id="site_model_news_edit_textarea_<%=news_type%>" name="site_model_news_edit_textarea" class="xheditor" rows="12" cols="80" style="width: 100%; height: 300px;"><%=news_content %></textarea>
                    </td>
                </tr>
                <tr>
                    <th>附件</th>
                    <td colspan="2">
                        <div id="news_edit_att_list_<%=news_type%>"></div>
                    </td>
                </tr>
                <tr>
                    <td colspan="3">
                        <table>
                            <tr>
                                <td>附件名称：</td>
                                <td>
                                    <input type="text" id="news_edit_att_title_<%=news_type%>" /></td>
                                <td>
                                    <input id="news_edit_att_<%=news_type%>" type="button" value="新增附件" /></td>
                                <td></td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
            <input name="news_key" type="hidden" value="<%=news_key %>" />
        </form>
    </div>
</body>
</html>
